home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #3 / Amiga Plus CD - 2002 - No. 03.iso / AmigaPlus / AmigaOS / Aplus_Dev / AP-Website / links / admin / related_main.php < prev    next >
Encoding:
PHP Script  |  2002-10-28  |  5.1 KB  |  196 lines

  1. <?
  2. // *******************************************************************
  3. //  admin/related_main.php
  4. // *******************************************************************
  5.  
  6. include("../include/config.php");
  7. include("../include/functions.php");
  8.  
  9. include("../include/common.php");
  10. $language = $gl["Language"];
  11.  
  12. include("../include/lang/$language.php");
  13.  
  14. include("../include/session.php");
  15. session_start();
  16. ?>
  17. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  18. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  19. <html>
  20. <head>
  21. <title></title>
  22. <link rel = "stylesheet" type = "text/css" href = "style.css" />
  23. </head>
  24. <?=$adm_body?>
  25. <?
  26.  
  27. if(isset($delete)){
  28.  
  29.     $delete = sql_query("
  30.         delete from
  31.             $tb_related
  32.         where
  33.             id='$id'
  34.     ");
  35. }
  36.  
  37. if(isset($add)){
  38.  
  39.     $insert = sql_query("
  40.         insert into $tb_related (
  41.             id,
  42.             cat_id,
  43.             rel_id
  44.         ) values (
  45.             '',
  46.             '$cat_id',
  47.             '$rel_id'
  48.         )
  49.     ");
  50. }
  51.  
  52. if(isset($update)){
  53.  
  54.     $update = sql_query("
  55.         update
  56.             $tb_related
  57.         set
  58.             rel_id = '$rel_id'
  59.         where
  60.             id = '$id'
  61.     ");
  62. }
  63.  
  64. ?>
  65. <table cellspacing="0" cellpadding="5" border="1" align="center" width="100%">
  66. <?
  67.  
  68. if(isset($list)){
  69.     echo "<input type=\"hidden\" name=\"list\" value=\"1\">";
  70. }
  71.  
  72. echo "<tr><td colspan=\"4\" class=\"theader\">Edit Related Categories";
  73. if(isset($update)){echo " - Update Complete";}
  74. if(isset($add)){echo " - Addition Complete";}
  75. if(isset($delete)){echo " - Deletion Complete";}
  76. echo "</td></tr>";
  77.  
  78. $category_name = sql_query("
  79.     select
  80.         *
  81.     from
  82.         $tb_categories
  83.     where
  84.         ID = '$Category'
  85. ");
  86.  
  87. $name = sql_fetch_array($category_name);
  88.  
  89. echo "<tr><td align=\"right\" class=\"text\">Category: </td><td colspan=\"3\" class=\"text\">";
  90.  
  91. unset($gcid);
  92.  
  93. if(isset($name["ID"])){
  94.     $gcid = $name["ID"];
  95. }
  96.  
  97. while($gcid > 0){
  98.     
  99.     $mlc_sql = "
  100.         select
  101.             *
  102.         from
  103.             $tb_categories
  104.         where
  105.             ID = '$gcid'
  106.     ";
  107.  
  108.     $mlc_query = sql_query($mlc_sql);
  109.     $mlc_array = sql_fetch_array($mlc_query);
  110.     $cat_array[] = $mlc_array["Category"];
  111.     $pid_array[] = $mlc_array["ID"];
  112.     $gcid = $mlc_array["PID"];
  113. }
  114.  
  115. $count = sizeof($pid_array);
  116.  
  117. for($depth=$count;$depth>=0;$depth--){    
  118.     
  119.     if($pid_array[$depth]){
  120.         
  121.         echo ">> ".ereg_replace("_"," ",($cat_array[$depth]));
  122.         
  123.         if($gcid > 0){
  124.             echo "  ";
  125.         }
  126.     }
  127. }
  128.  
  129. echo " </td></tr>";
  130.  
  131. $related = sql_query("
  132.     select
  133.         *
  134.     from
  135.         $tb_related
  136.     where
  137.         cat_id = '$Category'
  138. ");
  139.  
  140. while($related_array = sql_fetch_array($related)){
  141.     
  142.     echo "<tr><td align=\"right\" class=\"text\">Related: </td><form ";
  143.     echo "method=\"post\" action=\"related_main.php?" . session_name();
  144.     echo "=" . session_id() . "&id=" . $related_array["id"];
  145.     echo "&Category=" . $Category . "\"><td><select class=\"small\" ";
  146.     echo "name=\"rel_id\"><option value=\"0\">None</option>";
  147.     drop_related_cats($related_array["rel_id"], 0, "", $cats);
  148.     echo $cats;
  149.     unset($cats);
  150.     echo "</select></td><td><input class=\"button\" type=\"submit\" ";
  151.     echo "name=\"update\" value=\"Update\" /></td>";
  152.     if(isset($fm)){echo "<input type=\"hidden\" name=\"fm\" value=\"1\">";}
  153.     if(isset($list)){echo "<input type=\"hidden\" name=\"list\" value=\"1\">";}
  154.     echo "</form><form ";
  155.     echo "method=\"post\" action=\"related_main.php?" . session_name();
  156.     echo "=" . session_id() . "&id=" . $related_array["id"];
  157.     echo "&Category=" . $Category . "\"><td><input class=\"button\"";
  158.     echo "type=\"submit\" name=\"delete\" value=\"Delete\" /></td>";
  159.     if(isset($fm)){echo "<input type=\"hidden\" name=\"fm\" value=\"1\">";}
  160.     if(isset($list)){echo "<input type=\"hidden\" name=\"list\" value=\"1\">";}
  161.     echo "</form></tr>";
  162. }
  163.  
  164. echo "</table><br /><table cellspacing=\"0\" cellpadding=\"5\" border=\"1\" ";
  165. echo "align=\"center\" width=\"100%\">";
  166. echo "<tr><td class=\"theader\" colspan=\"2\">Add New Relationship</td></tr>";
  167. echo "<tr><form method=\"post\" action=\"related_main.php?" . session_name();
  168. echo "=" . session_id() . "&cat_id=" . $Category . "&Category=";
  169. echo $Category . "\"><td width=\"50%\" align=\"right\" class=\"text\">Related: ";
  170. echo "</td><td width=\"50%\"><select class=\"small\" name=\"rel_id\">";
  171. echo "<option value=\"0\">Please Select</option>";
  172. drop_related_cats(0, 0, "", $cats);
  173. echo $cats;
  174. unset($cats);
  175. echo "</select></td></tr><tr><td colspan=\"2\" align=\"center\"><input ";
  176. echo "class=\"button\" type=\"submit\" name=\"add\" value=\" Add New ";
  177. echo "Relationship -> \"></td>";
  178. if(isset($fm)){echo "<input type=\"hidden\" name=\"fm\" value=\"1\">";}
  179. if(isset($list)){echo "<input type=\"hidden\" name=\"list\" value=\"1\">";}
  180. echo "</form></tr>";
  181.  
  182. if((isset($update) || isset($add) || isset($delete)) && isset($fm)){
  183.     ?><tr>
  184.         <td colspan="2" align="center"><a href="categories_main.php?<?=session_name()?>=<?=session_id()?>">Return to Categories</a></td>
  185.     </tr><?
  186. }
  187.  
  188. if((isset($update) || isset($add) || isset($delete)) && isset($list)){
  189.     ?><tr>
  190.         <td colspan="2" align="center"><a href="unrelated.php?<?=session_name()?>=<?=session_id()?>">Return to Unrelated List</a></td>
  191.     </tr><?
  192. }
  193.  
  194. ?></table></body>
  195. </html>
  196.